package com.chixing.controller;

import com.chixing.service.ElasticSearchService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/search")
public class ElasticSearchController {
    @Autowired
    private ElasticSearchService elasticSearchService;

    @GetMapping( "/ES/{pageNum}")
    @ResponseBody
    public ServerResponse getByEs(@PathVariable(value = "pageNum",required = false) Integer pageNum,
                                  @RequestParam Float minPrice,
                                  @RequestParam Float maxPrice,
                                  @RequestParam Integer level,
                                  @RequestParam String type,
                                  @RequestParam String key){
        return elasticSearchService.getByElasticSearchSights(minPrice,maxPrice,level,type,key,pageNum);
    }
    @RequestMapping("/ES/Plan/{pageNum}")
    @ResponseBody
    public ServerResponse getByEsPlan(@PathVariable(value = "pageNum",required = false) Integer pageNum,
                                      @RequestParam Float minPrice,
                                      @RequestParam Float maxPrice,
                                      @RequestParam Integer perNum,
                                      @RequestParam Integer days,
                                      @RequestParam String key){
        return elasticSearchService.getByElasticSearchPlan(minPrice,maxPrice,perNum,days,key,pageNum);
    }
}
